package com.daniu.eureka.client.user.controller;


import com.daniu.eureka.client.api.user.dto.UserDTO;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/feign-user")
public class UserController {

    @RequestMapping(value = "/", method = RequestMethod.POST)
    public String createUser(@RequestBody UserDTO user) {
        System.out.println("创建用户，" + user);
        return "{'msg': 'success'}";
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public String updateUser(@PathVariable("id") Long id, @RequestBody UserDTO user) {
        System.out.println("更新用户，" + user);
        return "{'msg': 'success'}";
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    public String deleteUser(@PathVariable("id") Long id) {
        System.out.println("删除用户，id=" + id);
        return "{'msg': 'success'}";
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public UserDTO getById(@PathVariable("id") Long id) {
        System.out.println("查询用户，id=" + id);
        UserDTO user = new UserDTO();
        user.setName("张三");
        user.setId(12L);
        user.setAge(24);
        return user;
    }

}
